package com.cy.pj.goods.dao;

import com.cy.pj.goods.pojo.Goods;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

@Repository
public class GoodsDaoImpl implements GoodsDao{

    @Autowired
    private SqlSession sqlSession;

    @Override
    public List<Goods> findGoods() {
        return sqlSession.getMapper(GoodsDao.class).findGoods();
    }

    @Override
    public int deleteById(Integer id) {
        return sqlSession.getMapper(GoodsDao.class).deleteById(id);
    }

    @Override
    public int deleteObject(Integer... ids) {
        String statement = "com.cy.pj.goods.dao.GoodsDao.deleteObject";
        HashMap<Object, Object> map = new HashMap<>();
        map.put("ids", ids);
//        return sqlSession.getMapper(GoodsDao.class).deleteObject(map);
        return sqlSession.delete(statement,map);
    }


}
